ECHO=echo
BUILD_DIR=../../../build/bz

CPP=g++
INCLUDE_FLAGS=-I ../../include -I ..
CPP_FLAGS=$(INCLUDE_FLAGS) -Wall -Werror -nostartfiles -nostdlib -nodefaultlibs -fno-rtti -fno-exceptions -fno-stack-protector

LD=ld
LD_FLAGS=-r

AS=nasm
AS_FLAGS=-f elf

build: $(KOBJ)
all: clean build

$(KOBJ): $(OBJS)
	@$(ECHO) $(LD) $(LD_FLAGS) -o $@.ko $(OBJS)
	@$(LD) $(LD_FLAGS) -o $@.ko $(OBJS)
	@cp $@.ko $(BUILD_DIR)
	@rm -f *.o; rm -f *.ko; 

clean:
	@$(ECHO) "rm -rf *.o; rm -f *.ko;"
	@rm -f *.o; rm -f *.ko;	
	
%.o: %.cc
	@$(ECHO) $(CPP) $(CPP_FLAGS) -c $<
	@$(CPP) $(CPP_FLAGS) -c $<

%.o: %.asm	
	@$(ECHO) $(AS) $(AS_FLAGS) $<
	@$(AS) $(AS_FLAGS) $<